﻿using System;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows;

using ABCat.Core;
using ABCat.Core.Plugins.UI;
using ABCat.Shared.Properties;

namespace ABCat.UI.WPF.Models
{
	public sealed class NormalizationSettingsEditorViewModel : INotifyPropertyChanged
	{
		#region + Events +

		public event PropertyChangedEventHandler PropertyChanged;

		#endregion
		#region + Fields +

		private readonly Context _context;

		private bool _isActive;

		#endregion
		#region + Properties +

		public bool IsActive
		{
			get { return _isActive; }
			set
			{
				if (value.Equals(_isActive)) return;
				_isActive = value;
				OnPropertyChanged();
			}
		}

		public INormalizationSettingsEditorPlugin NormalizationSettingsEditorPlugin		{get; private set;}

		#endregion
		#region + Ctor +

		public NormalizationSettingsEditorViewModel(Context context)
		{
			_context = context;
			NormalizationSettingsEditorPlugin = _context.PluginsFactory.GetPlugins<INormalizationSettingsEditorPlugin>().First().CreateInstance<INormalizationSettingsEditorPlugin>(context);
		}

		#endregion
		#region + Logic +

		[NotifyPropertyChangedInvocator]
		private void OnPropertyChanged([CallerMemberName] string propertyName = null)
		{
			PropertyChangedEventHandler handler = PropertyChanged;
			if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
		}

		#endregion
	}
}